<#assign base=request.contextPath>
<!DOCTYPE html> 
<html>
	<head>
		<title>${title}</title>
		<meta charset="utf-8">
		<#include "common/reference.ftl" />
		<#include "common/ligerui.ftl" />
		<script type="text/javascript">
		<!--
			var ligerTable = null;
			$(function(){
				$('.chosen-select').chosen();
				
				ligerTable = $('#table_admin').ligerGrid({
					width:'98%',
					enabledSort:false,
					pageSizeOptions:[5,10,20,50,100,200],
					height:'auto',
					alternatingRow:true,
					url:'${base}/admin/getList',
					columns:[
						{display:'用户ID',name:'userId',id:'userId',align:'center'},
						{display:'用户名称',name:'userName',id:'userName',align:'center'},
						{display:'真实姓名',name:'trueName',id:'trueName',align:'center'},
						{display:'今天登录次数',name:'loginCount',id:'loginCount',align:'center'},
						{
							display:'是否在线',
							name:'isOnline',
							id:'isOnline',
							align:'center',
							render:function(row){
								var isOnline = row.isOnline;
						 		if(isOnline){
						 			return '是';
						 		}
						 		return '否';
							}
						},
						{
							display:'是否锁定',
							name:'isLocked',
							id:'isLocked',
							align:'center',
							render:function(row){
								var isLocked = row.isLocked;
						 		if(isLocked){
						 			return '是';
						 		}
						 		return '否';
							}
						},
						{
							display:'添加时间',
							name:'addTime',
							id:'addTime',
							align:'center',
							render:function(row){
								if(row.addTime > 0){
									return new Date(row.addTime * 1000).format('yyyy-MM-dd hh:mm');
								}
								return '-';
							}
						},
						{
							display:'登录时间',
							name:'lastLogin',
							id:'lastLogin',
							align:'center',
							render:function(row){
								if(row.lastLogin > 0){
									return new Date(row.lastLogin * 1000).format('yyyy-MM-dd hh:mm');
								}
								return '-';
							}
						},
						{display:'登录IP',name:'lastIp',id:'lastIp',align:'center'},
						{
							display:'是否启用',
							name:'enabled',
							id:'enabled',
							align:'center',
							render:function(row){
								var enabled = row.enabled;
						 		if(enabled){
						 			return '是';
						 		}
						 		return '否';
							}
						}
                        /*
						,
						{
							display:'操 作',
							align:'center',
							render:function(row){
								var userId = row.userId;
								if(row.userName == 'admin'){
									return [ 
										'<a class="edit" href="javascript:void(0)" onclick="setRoleItem('+userId+')"  title="设置角色">',
							                '<i class="fa fa-lock"></i>',
							            '</a>',
										'<a class="edit" href="javascript:void(0)" onclick="editItem('+userId+')"  title="编辑">',
							                '<i class="fa fa-edit"></i>',
							            '</a>'
							            ].join('');
								}
								else{
									return [ 
										'<a class="edit" href="javascript:void(0)" onclick="setRoleItem('+userId+')"  title="设置角色">',
							                '<i class="fa fa-lock"></i>',
							            '</a>',
							            '<a class="edit" href="javascript:void(0)" onclick="editItem('+userId+')"  title="设置区域">',
                                            '<i class="fa fa-square"></i>',
                                        '</a>',
										'<a class="edit" href="javascript:void(0)" onclick="editItem('+userId+')"  title="编辑">',
							                '<i class="fa fa-edit"></i>',
							            '</a>',
							            '<a class="remove" href="javascript:void(0)" onclick="removeItem('+userId+')" title="删除">',
							                '<i class="fa fa-remove"></i>',
							            '</a>'
							            ].join('');
								}
								
							}
						}*/
					]
				});
				
				function reload(){
					if(ligerTable){
						var userName = $('#txtUserName').val();
						ligerTable.setParm('userName',userName);
						ligerTable.reload();
					}
				}
				
				$('#btnSearch').click(function(){
					reload();
				});
			});
			
			function setRoleItem(userId){
				var url='${base}/admin/userRole/'+userId;
	            changePage(url);
			}
			
		    function editItem(userId){
	        	var url='${base}/admin/edit/'+userId;
	            changePage(url);
		    }
		    
		    function removeItem(userId){
		    	layer.confirm('确定要删除吗？',function(){
	    			$.ajax({
	            		url:'${base}/admin/remove/'+userId,
	            		type:'POST',
	            		data:{},
	            		dataType:'json',
	            		success:function(rst){
	            			layer.msg(rst.message);
	            			if(rst.status=='OK' && ligerTable != null ){
	            				ligerTable.reload();
	            			}
	            		}
	            	});	
	    		});
		    }
		//-->
		</script>
	</head>
	<body class="${configs["skinName"]}">
		<div class="page-content">
			<div class="row">
				<#include "common/breadcrumb.ftl">
				<div class="widget-box">
					<div class="widget-header widget-header-flat">
						<h5 class="lighter">
							<i class="fa fa-search"></i>
							用户查询
						</h5>
					</div>
					<div class="widget-body">
						<div class="widget-main">
							<div class="row">
								<div class="col-xs-12 col-sm-5">
									<div class="input-group">
										<span class="input-group-addon">管理员名称</span>
										<input id="txtUserName" type="text" class="search-query form-control" placeholder="请输入用户名称" />
										<span class="input-group-btn">
											<button id="btnSearch" type="button" class="btn btn-primary btn-sm">
												查询
												<i class="fa fa-search bigger-110"></i>
											</button>
										</span>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
				<div class="widget-box">
					<div class="widget-header widget-header-flat">
						<h5 class="lighter">
							<i class="fa fa-table"></i>
							用户列表
						</h5>
					</div>
					<div class="widget-body">
						<div id="table_admin"><div>
					</div>
				</div>
			</div>
		</div>
	</body>
</html>